home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / packet / 7pl215sr / 7plus.h < prev    next >
C/C++ Source or Header  |  1994-01-09  |  11KB  |  397 lines

  1. /*---------*\
  2. >  7plus.h  <
  3. \*---------*/
  4.  
  5. /* Uncomment next line, if compiling on AMIGA! */
  6. /* #define _AMIGA_ */
  7.  
  8. #define YES "yes"
  9. #define ALWAYS "always"
  10. #define NO  "no"
  11. #define EOS '\0'
  12. #define ON 0
  13. #define OFF 1
  14. #define LSEP 0x0a
  15. #define LSEPS "\x0a"
  16.  
  17. /* Some compilers are very strict abt the type of NULL-pointers */
  18. #define NULLFP ((FILE *) 0)
  19. #define NULLCP ((char *) 0)
  20.  
  21. /* Some compilers have difficulties using setvbuf().
  22.    Uncomment next line, if so (or add it to your definition block). */
  23. /* #define setvbuf(a,b,c,d) */
  24.  
  25. /** these includes should work anywhere **/
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include <time.h>
  29. #include <ctype.h>
  30. #include <errno.h>
  31. #include <limits.h>
  32.  
  33. /* Microsoft's Quick C has some different makros and function names **/
  34. #ifdef _QC
  35.  #define __MSDOS__
  36.  #define MAXDRIVE _MAX_DRIVE
  37.  #define MAXDIR   _MAX_DIR
  38.  #define MAXFILE  _MAX_FNAME
  39.  #define MAXEXT   _MAX_EXT
  40.  #define MAXPATH  _MAX_PATH
  41.  #define fnsplit  _splitpath
  42. #endif /* _QC */
  43.  
  44. #ifdef __MSDOS__
  45.  #ifdef __TURBOC__
  46.   #include <dir.h>
  47.   #include <io.h>
  48.  #endif
  49.  #include <conio.h>
  50.  #include <stdlib.h>
  51.  #include <sys/types.h>
  52.  #include <sys/stat.h>
  53.  #define PATHSEP "\\"
  54.  #define PATHCHAR '\\'
  55.  #define INDICATE 0xdb
  56.  #define TWO_CHAR_SEP
  57.  #define MAXFNAME MAXFILE+MAXEXT-1
  58.  #define _HAVE_FNSPLIT
  59.  #define _HAVE_CHSIZE
  60.  #define _HAVE_ICMP
  61.  #define _HAVE_GMTIME
  62.  #define _HAVE_MKTIME
  63.  #define _HAVE_GETCH
  64. #endif /* __MSDOS__ */
  65.  
  66. #ifdef __OS2__
  67.  #include <sys/types.h>
  68.  #include <sys/stat.h>
  69.  #include <io.h>
  70.  #ifdef __BORLANDC__
  71.   #define __IBMC__
  72.  #endif
  73.  #define MAXPATH   80 /* I don't have HPFS installed! */
  74.  #define MAXDRIVE  3
  75.  #define MAXDIR    66
  76.  #define MAXFILE   9
  77.  #define MAXEXT    5
  78.  #define PATHSEP "\\"
  79.  #define PATHCHAR '\\'
  80.  #define INDICATE 0xdb
  81.  #define TWO_CHAR_SEP
  82.  #define MAXFNAME MAXFILE+MAXEXT-1
  83.  #define _HAVE_CHSIZE
  84.  #define _HAVE_ICMP
  85.  #define _HAVE_GMTIME
  86.  #define _HAVE_MKTIME
  87.  #include <stdlib.h>
  88.  #ifdef __IBMC__
  89.   #define _HAVE_GETCH
  90.   #include <conio.h>
  91.  #endif
  92.  #ifdef __EMX__
  93.   #define chsize ftruncate
  94.   #include <termio.h>
  95.   struct termio sg[2];
  96.  #endif
  97. #endif /* __OS2__ */
  98.  
  99. #ifdef _AMIGA_
  100.  #define  _680X0_
  101.  #include <sys/types.h>
  102.  #include <sys/stat.h>
  103.  #include <stddef.h>
  104.  #include <proto/dos.h>
  105.  #include <libraries/dos.h>
  106.  #include <libraries/dosextens.h>
  107.  #include <exec/memory.h>
  108.  #include <stdlib.h>
  109.  #undef  YES
  110.  #define YES ""
  111.  #undef  NO
  112.  #define NO ""
  113.  #undef ALWAYS
  114.  #define ALWAYS ""
  115.  #define SEEK_SET 0
  116.  #define SEEK_CUR 1
  117.  #define SEEK_END 2
  118.  #define MAXPATH  300
  119.  #define MAXDRIVE 5
  120.  #define MAXDIR   220
  121.  #define MAXFILE  31
  122.  #define MAXEXT   31
  123.  #define PATHSEP  "/"
  124.  #define PATHCHAR '/'
  125.  #define INDICATE '*'
  126.  #define MAXFNAME MAXFILE
  127.  #define _HAVE_GETCH
  128.  #define getch getchar
  129. #endif /* _AMIGA_ */
  130.  
  131. #ifdef __TOS__
  132.  #define MAXPATH   119
  133.  #define MAXDRIVE  3
  134.  #define MAXDIR    102
  135.  #define MAXFILE   9
  136.  #define MAXEXT    5
  137.  #define PATHSEP "\\"
  138.  #define PATHCHAR '\\'
  139.  #define INDICATE 0xdb
  140.  #define TWO_CHAR_SEP
  141.  #define MAXFNAME MAXFILE+MAXEXT-1
  142.  #define _HAVE_GETCH
  143.  #include <stdlib.h>
  144.  #include <ext.h>
  145.  /* quick & dirty, swaps upper and lower word                      */
  146.  unsigned long swapl(unsigned long l)0x4840; /* opcode for SWAP D0 */
  147.  /* needed for timestamp-functions    (Odo,DL1XAO)                 */
  148. #endif /* __TOS__ */
  149.  
  150.  
  151. #ifdef __unix__
  152.  #include <sys/types.h>
  153.  #include <sys/stat.h>
  154.  #ifdef __M_XENIX__
  155.   #include <malloc.h>
  156.   #define SEEK_CUR 1
  157.   #define SEEK_END 2
  158.   #define SEEK_SET 0
  159.   typedef unsigned size_t;
  160.  #endif
  161.  /* assumed limits (hope reasonable !!! DF6NL) */
  162.  #define MAXPATH 256
  163.  #define MAXDRIVE 16
  164.  #define MAXDIR 256
  165.  #define MAXFILE 32
  166.  #define MAXEXT 32
  167.  #define PATHSEP "/"
  168.  #define PATHCHAR '/'
  169.  #define INDICATE '*'
  170.  #define MAXFNAME MAXFILE
  171.  #ifdef SYSV
  172.   #include <unistd.h> /* not sure, if this one is really necessary */
  173.  #endif
  174.  #ifdef __i386__
  175.   #ifndef SYSV
  176.    #define SYSV
  177.   #endif
  178.  #endif
  179.  
  180.  #ifdef SYSV
  181.   #include <termio.h>
  182.   struct termio sg[2];
  183.  #else
  184.   #include <sgtty.h>
  185.   struct sgttyb sg[2];
  186.  #endif
  187. #endif /* __unix__ */
  188.  
  189. #ifdef OSK
  190.  /* Assumed limits */
  191.  #include <types.h>
  192.  #include <stat.h>
  193.  #define _680X0_
  194.  #define _IOFBF 0
  195.  #undef YES
  196.  #undef NO
  197.  #undef ALWAYS
  198.  #define YES "es"
  199.  #define NO  "o"
  200.  #define ALWAYS "lways"
  201.  #undef LSEP
  202.  #undef LSEPS
  203.  #define LSEP 0x0d
  204.  #define LSEPS "\x0d"
  205.  #define MAXPATH 256
  206.  #define MAXDRIVE 16
  207.  #define MAXDIR 256
  208.  #define MAXFILE 32
  209.  #define MAXEXT 256
  210.  #define PATHSEP "/"
  211.  #define PATHCHAR '/'
  212.  #define INDICATE '*'
  213.  #define MAXFNAME MAXFILE
  214.  #define _HAVE_GETCH
  215.  #define getch()  getc(stdin)
  216.  char *strsave(const char *);
  217.  #define strdup  strsave
  218.  #define SEEK_SET   0
  219.  #define SEEK_CUR   1
  220.  #define SEEK_END   2
  221.  #include <termcap.h>
  222.  #include <stdlib.h>
  223. #endif /* OSK */
  224.  
  225. #define MAXFPATH (MAXDRIVE+MAXDIR-1)
  226.  
  227. /* flags for fopen() */
  228. #define OPEN_READ_TEXT "r"
  229. #define OPEN_WRITE_TEXT "w"
  230. #define OPEN_APPEND_TEXT "a"
  231. #define OPEN_RANDOM_TEXT "r+"
  232. #ifdef TWO_CHAR_SEP
  233.  /* This is for systems that convert LF to CR/LF in textmode */
  234.  #define OPEN_READ_BINARY "rb"
  235.  #define OPEN_WRITE_BINARY "wb"
  236.  #define OPEN_APPEND_BINARY "ab"
  237.  #define OPEN_RANDOM_BINARY "r+b"
  238. #else
  239.  /* And this, if there is no conversion */
  240.  #define OPEN_READ_BINARY "r"
  241.  #define OPEN_WRITE_BINARY "w"
  242.  #define OPEN_APPEND_BINARY "a"
  243.  #define OPEN_RANDOM_BINARY "r+"
  244. #endif
  245.  
  246. /** shorthands for unsigned types **/
  247. typedef unsigned char byte;  /* 8bit unsigned char */
  248. #ifdef __unix__
  249.  #ifdef __vax__
  250.    typedef u_long ulong;
  251.  #endif
  252.  #ifdef __M_XENIX__
  253.    typedef unsigned long ulong;
  254.  #endif
  255. #else
  256.  typedef unsigned int  uint;  /* 16 or 32bit unsigned int */
  257.  typedef unsigned long ulong; /* 32bit unsigned long      */
  258. #endif
  259.  
  260. struct  m_index
  261. {
  262.   char  filename[14];  /*12  chars +2*/
  263.   char  full_name[258];/*256 chars +2*/
  264.   ulong length;
  265.   ulong timestamp;
  266.   uint  splitsize;
  267.   ulong lines_ok[4090];
  268.   long  lines_left;
  269. };
  270.  
  271. /*********************** macros *************************/
  272.  
  273. #define crc_calc(x,y) (x)=crctab[(x)>>8]^((((x)&255)<<8)|(byte)(y))
  274.  
  275. /***************** function prototypes ******************/
  276.  
  277. /** 7plus.c **/
  278. int   go_at_it       (int argc, char **argv);
  279. int   screenlength   (void);
  280.  
  281. /** encode.c **/
  282. int   encode_file    (char *name, long blocksize, char *searchbin,
  283.               int first_part, int last_part, int join,
  284.               char *head_foot);
  285. int   read_tb        (char *name, char *go_top, char *go_bottom);
  286. int   top_bottom     (FILE *wfile, char *top_bot, char *orgname,
  287.                                                           int part, int parts);
  288. /** decode.c **/
  289. int   control_decode (char *name);
  290. int   decode_file    (char *name, int flag);
  291. void  decode_n_write (FILE *raus, char *p, int length);
  292. void  w_index_err    (struct m_index *idxptr, const char *localname, int flag);
  293. int   make_new_err   (const char *name);
  294. void  progress       (const char *filename, int part, int of_parts,
  295.                                 long errors, long rebuilt, const char *status);
  296. /* correct.c */
  297. int   correct_meta   (char *name, int itsacor, int quietmode);
  298.  
  299. /** util.c **/
  300. char  *my_fgets      (char *string, register n, FILE *rein);
  301. int   my_putc        (int  outchar, FILE *out);
  302. void  crc_n_lnum     (uint *crc, int *linenumber, char *line);
  303. void  crc2           (uint *crc, char *line);
  304. void  add_crc2       (char *line);
  305. int   mcrc           (char *line, int flag);
  306. int   read_index     (FILE *ifile, struct m_index *idxptr);
  307. int   write_index    (FILE *ifile, struct m_index *idxptr, int flag);
  308. ulong read_ulong     (FILE *in);
  309. uint  read_uint      (FILE *in);
  310. void  write_ulong    (FILE *out, ulong val);
  311. void  write_uint     (FILE *out, uint val);
  312. int   crc_file       (const char *file, const char *s1, const char *s2,
  313.                                                                      int flag);
  314. int   copy_file      (const char *to,  const char *from, ulong timestamp);
  315. void  replace        (const char *old, const char *new,  ulong timestamp);
  316. void  kill_em        (const char *name, const char *inpath, const char *one,
  317.                       const char *two,  const char *three,  const char *four,
  318.                       const char *five, int no_lf);
  319. void  kill_dest      (FILE *in, FILE *out, const char *name);
  320. int   test_exist     (const char *filename);
  321. int   test_file      (FILE *in, char *destnam, int flag, int namsize);
  322. void  init_decodetab (void);
  323. void  init_codetab   (void);
  324. void  init_crctab    (void);
  325. void  build_DOS_name (char *name, char *ext);
  326. void  strip          (char *string);
  327. #if defined (__MSDOS__) || (__TOS__)
  328.  ulong get_filetime   (FILE *_file);
  329.  void  set_filetime   (FILE *_file, ulong ftimestamp);
  330. #else
  331.  #ifndef _HAVE_GMTIME
  332.   struct tm *__offtime (const time_t *t, long int offset);
  333.   struct tm *gmtime    (const time_t *t);
  334.  #endif
  335.  #ifndef _HAVE_MKTIME
  336.   time_t    mktime     (register struct tm *tp);
  337.  #endif
  338.  ulong get_filetime (const char *filename);
  339.  void  set_filetime (const char *filename, ulong ftimestamp);
  340. #endif
  341. uint  get_hex        (char *hex);
  342. #ifndef _HAVE_FNSPLIT
  343.   void  fnsplit      (char *pth, char *dr, char *pa, char *fn, char *ft);
  344. #endif
  345. #ifndef _HAVE_ICMP
  346.   char  *strupr      (char *string);
  347.   char  *strlwr      (char *string);
  348.   char  *strcnvt     (char *string, int flag);
  349.   int   stricmp      (const char *s1, const char *s2);
  350.   int   strnicmp     (const char *s1, const char *s2, size_t n);
  351. #endif
  352. #ifndef _HAVE_GETCH
  353.  int    getch        (void);
  354. #endif
  355.  
  356. /** rebuild.c **/
  357. int   rebuild        (char *line, int flag);
  358.  
  359. /** extract.c **/
  360. int   extract_files  (char *name, char *search);
  361.  
  362. /** join.c **/
  363. int   join_control   (char *file1, char *file2);
  364. int   join_err       (char *file1, char *file2);
  365.  
  366. /** unix.c **/
  367. #ifdef __unix__
  368.  #ifdef __i386__
  369.   #ifndef _HAVE_STRSTR
  370.    char     *strstr    (const char *s1, const char *s2);
  371.   #endif  /* _HAVE_STRSTR */
  372.   int      rename     (const char *s1, const char *s2);
  373.  #endif /* __i386__ */
  374.  
  375.  #ifdef __vax__
  376.   #ifdef __STDC__
  377.    extern char *strdup (const char *);
  378.   #else
  379.    extern char *strdup ();
  380.   #endif  /* __STDC__ */
  381.  #endif  /* __vax__ */
  382. #endif /* __unix__ */
  383.  
  384. #ifdef OSK
  385.  int  rename        (const char *s1, const char *s2);
  386.  int  my_getch      (void);
  387.  int  setvbuf       (FILE * stream, char *buf, int bufmode, size_t size);
  388.  #ifndef _HAVE_STRSTR
  389.   const char *strstr (const char *src, const char *sub);
  390.  #endif
  391.  void check_fn      (register char *fn);
  392.  void set_autolf    (int flag);
  393. #else
  394.  #define set_autolf(x)
  395.  #define check_fn(x)
  396. #endif
  397.